﻿using System.Collections.Generic;
using System;

namespace Inovout.Gis.Geometry
{
    public abstract class GeometryFactory
    {
        private static List<GeometryFactory> geometryFactories = new List<GeometryFactory>();
        public static void RegiesterGeometryFactory(params GeometryFactory[] factories)
        {
            geometryFactories.AddRange(factories);
        }
        public static IGeometryInfo CreateGeometry(IGeometryInfo geometryInfo)
        {
            LayerMapping layerMapping = SessionFactoryHolder.Instance.GetConfiguration(geometryInfo.Layer.Name)
                .GetLayerMapping(geometryInfo.Layer.Name);
            return Activator.CreateInstance(layerMapping.GeometryType, geometryInfo) as IGeometryInfo;
            //foreach (GeometryFactory geometryFactory in geometryFactories)
            //{
            //    IGeometryInfo geometry = geometryFactory.Create(arcGeometry);
            //    if (geometry != null)
            //    {
            //        return geometry;
            //    }
            //}
            //return arcGeometry;
        }
        public abstract IGeometryInfo Create(IGeometryInfo geometryInfo);
    }
}
